﻿using System;
using System.Text.Json;
namespace CommandLinex
{
    public class JsonProcessor : ICommandLineValueProcessor
    {
        public object Process(string value, Type targetType)
        {
            try
            {
                return JsonSerializer.Deserialize(value, targetType);
            }
            catch (JsonException ex)
            {
                throw new ArgumentException($"Invalid JSON format for value: {value}", ex);
            }
        }
    }
}